#include <unistd.h>
#include <stdlib.h>
#include <stdio.h>
#include <string.h>

int main(){
	int file_pipes[2];
	char buffer[256+1];
	memset(buffer,'\0',sizeof(buffer));
	
	if(pipe(file_pipes)==0){
		int fork_result=fork();
		if(fork_result==-1){
			fprintf(stderr,"fork error");
			exit(1);
		}else if(fork_result==0){
			printf("child ok\n");
			int wc=read(file_pipes[0],buffer,256);
			printf("read wc:%d",wc);
		}else{
			printf("parent ok\n");
			char* note="hello";
			int wc=write(file_pipes[1],note,strlen(note));
			printf("write char:%d",wc);
			int st;
			wait(&st);
		}
	}
	return 0;
}